// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    const wxContent = cloud.getWXContext()
    const templateId = 'WZ3EC8uFfZzXJvbbalJIsAFvt027fG_1tMjaNgAz-Rs'
    console.log("event", event)
    console.log("wxContent", wxContent)
    const result = await cloud.openapi.subscribeMessage.send({
      touser: wxContent.OPENID,
      page: `page/blog-comment/blog-comment?blogId=${event.blogId}`,
      /* lang: 'zh_CN', */
      data: {
        thing1: {
          value: '评价完成'
        },
        thing2: {
          value:event.content
        },
      },
      templateId: templateId,
      miniprogramState: 'trial'
    })
    return result
  } catch (err) {
    return err
  }
}